/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author vodangbinhtay
 */
public class DBConfig {
    public  Connection OpenConnect(){
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
           return DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Hotel","sa","123456");
        } catch (SQLException ex) {
            Logger.getLogger(DBConfig.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DBConfig.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }         
    }
    public static void CloseConnect(Connection con){
        if(con!=null){
            try {
                con.close();
            } catch (SQLException ex) {
                Logger.getLogger(DBConfig.class.getName()).log(Level.SEVERE, null, ex);
            }
                    
        }
    }
    
}
